View(price_index)
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
View(quantity)
View(quantity)
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
View(quantity)
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
data.table(quantity)
quantity = t(1/price_index) %>% as.data.table(.)
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
View(quantity)
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
View(quantity)
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
test = melt(quantity)
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
View(test)
quantity = t(1/price_index) %>% as.data.table(.)
names(quantity) = gr$Country
quantity$year = t
quantity = t(1/price_index) %>% as.data.table(.)
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
View(test)
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot = ggplot() +
geom_line(data = quantity, aes(x = year, y = value, col = variable))
quant_plot
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
View(quantity)
quantity$title = quantity$Deflator
quantity$title[quantity$Time != max(t)] = NA
View(quantity)
quant_plot = ggplot() +
geom_line(data = quantity, aes(x = Time, y = `Computer Output`, col = Deflator)) +
geom_text(data = quantity, aes(x = Time, y = `Computer Output`, label = title))
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
box = ggplot() +
geom_bar(data = gr, aes(x = Country, y = growth_rate))
box
box = ggplot() +
geom_bar(data = gr, aes(x = Country, y = growth_rate, stat="identity"))
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
box = ggplot() +
geom_bar(data = gr, aes(x = Country, y = growth_rate), stat="identity")
box
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
box
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
gr$Country =   reorder(gr$Country, gr$growth_rate, FUN= max)
box = ggplot() +
geom_bar(data = gr, aes(x = Country, y = growth_rate*100), stat="identity")
box
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
names(quantity) = as.character(gr$Country)
quantity$time = t
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
quant_plot
box = ggplot() +
geom_bar(data = gr, aes(x = Country, y = growth_rate*100, fill = Country), stat="identity")
box
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
wd = gsub("Figures", "Data/World Bank", dir)
library(data.table)
library(ggplot2)
library(gridExtra)
library(reshape2)
library(matrixStats)
library(reshape2)
library(here)
library(magrittr)
text.size = 10
dir = here()
# GDP Inflation
wd = gsub("Figures", "Data/World Bank", dir)
setwd(wd)
wdi = fread("wdi.csv")
# selected Computer Deflator
##################################################################
wd = gsub("Figures", "Data/OECD_computer_deflator", dir)
setwd(wd)
gr = fread("computers_price_change.csv")
test = wdi[country %in% gr$Country]
View(test)
test = wdi[country %in% gr$Country & year %in% 1995:2001]
View(test)
geom_mean = function(x){ exp(mean(log(x)))}
geo_mean = function(x){ exp(mean(log(x)))}
test = wdi[, geo_mean(1 + NY.GDP.DEFL.KD.ZG/100)]
View(wdi)
# GDP Inflation
wd = gsub("Figures", "Data/World Bank", dir)
setwd(wd)
wdi = fread("wdi.csv")
wdi = wdi[country %in% gr$Country & year %in% 1995:2001]
geo_mean = function(x){ exp(mean(log(x)))}
test = wdi[, geo_mean(1 + NY.GDP.DEFL.KD.ZG/100)]
wdi = fread("wdi.csv") %>% na.omit()
wdi = wdi[country %in% gr$Country & year %in% 1995:2001]
geo_mean = function(x){ exp(mean(log(x)))}
test = wdi[, geo_mean(1 + NY.GDP.DEFL.KD.ZG/100)]
test = wdi[, geo_mean(1 + NY.GDP.DEFL.KD.ZG/100), by = country]
View(test)
test = wdi[, geo_mean(1 + NY.GDP.DEFL.KD.ZG/100) -1  , by = country]
View(test)
geo_mean = function(x){ exp(mean(log(x)))}
inflation = wdi[, geo_mean(1 + NY.GDP.DEFL.KD.ZG/100) -1  , by = country]
View(gr)
gr
inflation = wdi[, geo_mean(1 + NY.GDP.DEFL.KD.ZG/100) -1  , by = country]
View(inflation)
geo_mean = function(x){ exp(mean(log(x)))}
inflation = wdi[, geo_mean(1 + NY.GDP.DEFL.KD.ZG/100) -1  , by = country]
gr = gr[order(Country)]
computer_inflation = fread("computers_price_change.csv")
wd = gsub("Figures", "Data/OECD_computer_deflator", dir)
setwd(wd)
computer_inflation = fread("computers_price_change.csv")
geo_mean = function(x){ exp(mean(log(x)))}
inflation = wdi[, geo_mean(1 + NY.GDP.DEFL.KD.ZG/100) -1  , by = country]
computer_inflation = computer_inflation[order(Country)]
inflation = inflation[order(country)]
computer_inflation = computer_inflation[order(Country)]
computer_quality =  inflation$V1 -    computer_inflation$growth_rate
computer_inflation$quality = inflation$V1 - computer_inflation$growth_rate
View(computer_inflation)
library(data.table)
library(ggplot2)
library(gridExtra)
library(reshape2)
library(matrixStats)
library(reshape2)
library(here)
library(magrittr)
text.size = 10
dir = here()
# GDP Inflation
wd = gsub("Figures", "Data/World Bank", dir)
setwd(wd)
wdi = fread("wdi.csv") %>% na.omit()
wdi = wdi[country %in% gr$Country & year %in% 1995:2001]
# selected Computer Deflator
##################################################################
wd = gsub("Figures", "Data/OECD_computer_deflator", dir)
setwd(wd)
computer_inflation = fread("computers_price_change.csv")
inflation_computer = fread("computers_price_change.csv")
geo_mean = function(x){ exp(mean(log(x)))}
inflation_gdp = wdi[, geo_mean(1 + NY.GDP.DEFL.KD.ZG/100) -1  , by = country]
inflation = merge(inflation_computer, inflation_gdp, by = "country")
View(inflation)
library(data.table)
library(ggplot2)
library(gridExtra)
library(reshape2)
library(matrixStats)
library(reshape2)
library(here)
library(magrittr)
text.size = 10
dir = here()
# GDP Inflation
wd = gsub("Figures", "Data/World Bank", dir)
setwd(wd)
wdi = fread("wdi.csv") %>% na.omit()
wdi = wdi[country %in% gr$Country & year %in% 1995:2001]
# selected Computer Deflator
##################################################################
wd = gsub("Figures", "Data/OECD_computer_deflator", dir)
setwd(wd)
inflation_computer = fread("computers_price_change.csv")
# remove nationa inflation from computer price index
# mean inflation rate, 1995 - 2001
geo_mean = function(x){ exp(mean(log(x)))}
inflation_gdp = wdi[, geo_mean(1 + NY.GDP.DEFL.KD.ZG/100) -1  , by = country]
inflation = merge(inflation_computer, inflation_gdp, by = "country")
View(inflation)
inflation_gdp = wdi[, .( general_inflation =   geo_mean(1 + NY.GDP.DEFL.KD.ZG/100) -1 ) , by = country]
inflation = merge(inflation_computer, inflation_gdp, by = "country")
library(data.table)
library(ggplot2)
library(gridExtra)
library(reshape2)
library(matrixStats)
library(reshape2)
library(here)
library(magrittr)
text.size = 10
dir = here()
# GDP Inflation
wd = gsub("Figures", "Data/World Bank", dir)
setwd(wd)
wdi = fread("wdi.csv") %>% na.omit()
wdi = wdi[country %in% gr$Country & year %in% 1995:2001]
# selected Computer Deflator
##################################################################
wd = gsub("Figures", "Data/OECD_computer_deflator", dir)
setwd(wd)
inflation_computer = fread("computers_price_change.csv")
# remove nationa inflation from computer price index
# mean inflation rate, 1995 - 2001
geo_mean = function(x){ exp(mean(log(x)))}
inflation_gdp = wdi[, .( general_inflation =   geo_mean(1 + NY.GDP.DEFL.KD.ZG/100) -1 ) , by = country]
inflation = merge(inflation_computer, inflation_gdp, by = "country")
View(inflation)
inflation$computer_quality = inflation$general_inflation - inflation$computer_inflation
View(inflation)
inflation$country =   reorder(inflation$country , inflation$computer_quality, FUN= max)
box = ggplot() +
geom_bar(data = gr, aes(x = country, y = computer_quality, fill = country), stat="identity") +
theme_bw() +
theme(panel.border = element_rect(color = "black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
legend.position = "none",
plot.title = element_text(face = "bold", hjust = 0.5, size = rel(0.9), vjust = -0.5),
axis.line = element_line(color = "black"),
axis.title.x = element_blank(),
axis.title.y = element_text(vjust= 1, size=rel(0.9)),
axis.text.x = element_text(margin=margin(5,5,3,0,"pt"), angle = 45, hjust = 1),
axis.text.y = element_text(margin=margin(3,5,0,3,"pt")),
axis.ticks.length = unit(-0.7, "mm"),
text=element_text(size = text.size, family="Times"))
box = ggplot() +
geom_bar(data = inflation, aes(x = country, y = computer_quality, fill = country), stat="identity") +
theme_bw() +
theme(panel.border = element_rect(color = "black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
legend.position = "none",
plot.title = element_text(face = "bold", hjust = 0.5, size = rel(0.9), vjust = -0.5),
axis.line = element_line(color = "black"),
axis.title.x = element_blank(),
axis.title.y = element_text(vjust= 1, size=rel(0.9)),
axis.text.x = element_text(margin=margin(5,5,3,0,"pt"), angle = 45, hjust = 1),
axis.text.y = element_text(margin=margin(3,5,0,3,"pt")),
axis.ticks.length = unit(-0.7, "mm"),
text=element_text(size = text.size, family="Times"))
box
growth_func = function(t){  (1 + inflation$computer_quality)^(t)  }
t = 0:30
quantity = sapply(t, growth_func)
View(quantity)
quantity = sapply(t, growth_func) %>% t(.)  %>% as.data.table(.)
names(quantity) = as.character(gr$Country)
quantity$time = t
names(quantity) = as.character(inflation$country)
View(inflation)
names(quantity) = as.character(inflation$country)
quantity = sapply(t, growth_func) %>% t(.)  %>% as.data.table(.)
names(quantity) = as.character(inflation$country)
quantity$time = t
quantity = melt(quantity, id.vars = "time")
names(quantity) = c("time", "deflator", "output")
quantity$deflator =   reorder(quantity$deflator, -quantity$output, FUN= max)
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
wdi = wdi[country %in% inflation_computer$country & year %in% 1995:2001]
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
as.character(inflation$country)
View(inflation)
quantity$deflator =   reorder(quantity$deflator, -quantity$output, FUN= max)
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/computers.R')
View(quantity)
quantity = sapply(t, growth_func)
View(quantity)
source('~/Desktop/aggregation/Supplementary Material/Figures/apple_gdp.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/apple_gdp.R')
dir
library(here)
dir = here()
wd = paste(dir, "/clipart")
img <- readPNG("apple.png")
library(data.table)
library(ggplot2)
library(gridExtra)
library(magrittr)
library(png)
library(grid)
library(here)
text.size = 10
dir = here()
w = fread("bread_apple.csv")
d = fread("apple_econ.csv")
gdp_vol = t(t(d)*w$Volume) %>% rowSums()
gdp_vol = gdp_vol/gdp_vol[1]
gdp_mass = t(t(d)*w$Mass) %>% rowSums()
gdp_mass = gdp_mass/gdp_mass[1]
gdp_energy = t(t(d)*w$Energy) %>% rowSums()
gdp_energy = gdp_energy/gdp_energy[1]
gdp = c(gdp_vol, gdp_mass, gdp_energy )
unit  = rep( c("Volume", "Mass", "Energy"), each = 30)
time = rep(1:30, 3)
output = data.table(time, gdp, unit)
d$time = 1:30
wd = paste(dir, "/clipart")
img <- readPNG("apple.png")
apple = rasterGrob(img, interpolate = T)
img <- readPNG("bread.png")
bread = rasterGrob(img, interpolate = T)
setwd(wd)
wd = paste(dir, "/clipart")
setwd(wd)
wd
wd = paste(dir, "/clipart", sep = "")
setwd(wd)
source('~/Desktop/aggregation/Supplementary Material/Figures/apple_gdp.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/apple_gdp.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/apple_gdp.R')
source('~/Desktop/aggregation/Supplementary Material/Figures/prices.R')
wd = wd = gsub("Figures", "Data/Vintage_gdp", dir)
setwd(wd)
g = fread("vintage_gdp.csv")
View(g)
library(data.table)
library(ggplot2)
library(magrittr)
library(here)
dir = here()
setwd(dir)
# clean data
v = fread("routputMvQd.csv")
m = 1947 + 284/4
y = seq(1947, m - 0.25, 0.25)
v$DATE = y
# population
wd = gsub("Vintage_gdp", "US_population", dir)
setwd(wd)
pop = fread("us_pop_quarterly.csv")
pop = pop[year %in% y]
# convert to gdp per capita
v[-1,] = v[-1,]/pop$population
View(v)
test = v[-1,]/pop$population
View(test)
for(i in 2:ncol(v)){
v[i,] = v[i,] /pop$population
}
ncol(v)
v[, -1] = v[, -1] / pop$population
v[, -1]
v[,i] = v[,i] /pop$population
v[,i]
f = function(x){x/pop$population}
v[,-1]
test = v[,-1]
View(test)
test = apply(v[,-1], 2, f)
View(test)
test = apply(v[,-1], 1, f)
View(pop)
test = apply(v[,-1], 2, f)
View(test)
library(data.table)
library(ggplot2)
library(magrittr)
library(here)
dir = here()
setwd(dir)
# clean data
v = fread("routputMvQd.csv")
m = 1947 + 284/4
y = seq(1947, m - 0.25, 0.25)
v$DATE = y
# population
wd = gsub("Vintage_gdp", "US_population", dir)
setwd(wd)
pop = fread("us_pop_quarterly.csv")
pop = pop[year %in% y]
# long format
v = melt(v, id.vars= "DATE")
v$value = gsub("#N/A","", v$value)
v$value = as.numeric(v$value)
v$variable = as.character(v$variable)
View(v)
v$test = v$DATE / pop$population
View(test)
library(data.table)
library(ggplot2)
library(magrittr)
library(here)
dir = here()
setwd(dir)
# clean data
v = fread("routputMvQd.csv")
m = 1947 + 284/4
y = seq(1947, m - 0.25, 0.25)
v$DATE = y
# population
wd = gsub("Vintage_gdp", "US_population", dir)
setwd(wd)
pop = fread("us_pop_quarterly.csv")
pop = pop[year %in% y]
# long format
v = melt(v, id.vars= "DATE")
v$value = gsub("#N/A","", v$value)
v$value = as.numeric(v$value)
v$variable = as.character(v$variable)
v$test = v$DATE / pop$population
View(v)
View(v)
source('~/Desktop/aggregation/Supplementary Material/Data/Vintage_gdp/vintage_workbook.R')
